home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OInterfaces / SCSI.mod < prev    next >
Encoding:
Text File  |  1995-08-10  |  41.2 KB  |  912 lines  |  [TEXT/MPS ]

  1. (*
  2.      File:        SCSI.mod
  3.  
  4.      Contains:    SCSI Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs.applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. *)
  19.  
  20. (*$TAGS-*)
  21. (*$CALLING PASCAL*)
  22. MODULE SCSI;
  23.  
  24. IMPORT SYSTEM, Types;
  25.  
  26. (* $PUSH*)
  27. (* $ALIGN MAC68K*)
  28. (* $LibExport+*)
  29.  
  30. CONST
  31.     scInc*                        = 1;
  32.     scNoInc*                        = 2;
  33.     scAdd*                        = 3;
  34.     scMove*                        = 4;
  35.     scLoop*                        = 5;
  36.     scNop*                        = 6;
  37.     scStop*                        = 7;
  38.     scComp*                        = 8;
  39.  
  40. (* SCSI Manager errors *)
  41.     scCommErr*                    = 2;                            (* communications error, operation timeout *)
  42.     scArbNBErr*                    = 3;                            (* arbitration timeout waiting for not BSY *)
  43.     scBadParmsErr*                = 4;                            (* bad parameter or TIB opcode *)
  44.     scPhaseErr*                    = 5;                            (* SCSI bus not in correct phase for attempted operation *)
  45.     scCompareErr*                = 6;                            (* data compare error *)
  46.     scMgrBusyErr*                = 7;                            (* SCSI Manager busy  *)
  47.     scSequenceErr*                = 8;                            (* attempted operation is out of sequence *)
  48.     scBusTOErr*                    = 9;                            (* CPU bus timeout *)
  49.     scComplPhaseErr*                = 10;                            (* SCSI bus wasn't in Status phase *)
  50.  
  51. (* Signatures *)
  52.     sbSIGWord*                    = $4552;                        (* signature word for Block 0 ('ER') *)
  53.     sbMac*                        = 1;                            (* system type for Mac *)
  54.     pMapSIG*                        = $504D;                        (* partition map signature ('PM') *)
  55.     pdSigWord*                    = $5453;
  56.  
  57.     oldPMSigWord*                = pdSigWord;
  58.     newPMSigWord*                = pMapSIG;
  59.  
  60. (* Driver Descriptor Map *)
  61.  
  62. TYPE
  63.     Block0* = (*ΔΔPACKEDΔΔ*) RECORD
  64.         sbSig*:                    INTEGER;                                (* unique value for SCSI block 0 *)
  65.         sbBlkSize*:                INTEGER;                                (* block size of device *)
  66.         sbBlkCount*:                LONGINT;                                (* number of blocks on device *)
  67.         sbDevType*:                INTEGER;                                (* device type *)
  68.         sbDevId*:                INTEGER;                                (* device id *)
  69.         sbData*:                    LONGINT;                                (* not used *)
  70.         sbDrvrCount*:            INTEGER;                                (* driver descriptor count *)
  71.         ddBlock*:                LONGINT;                                (* 1st driver's starting block *)
  72.         ddSize*:                    INTEGER;                                (* size of 1st driver (512-byte blks) *)
  73.         ddType*:                    INTEGER;                                (* system type (1 for Mac+) *)
  74.         ddPad*:                    ARRAY 243 (*ΔΔ[0..242]ΔΔ*) OF INTEGER;                (* ARRAY[0..242] OF INTEGER; not used *)
  75.     END;
  76.  
  77. (* Partition Map Entry *)
  78.     Partition* = (*ΔΔPACKEDΔΔ*) RECORD
  79.         pmSig*:                    INTEGER;                                (* unique value for map entry blk *)
  80.         pmSigPad*:                INTEGER;                                (* currently unused *)
  81.         pmMapBlkCnt*:            LONGINT;                                (* # of blks in partition map *)
  82.         pmPyPartStart*:            LONGINT;                                (* physical start blk of partition *)
  83.         pmPartBlkCnt*:            LONGINT;                                (* # of blks in this partition *)
  84.         pmPartName*:                (*ΔΔPACKEDΔΔ*) ARRAY 32 (*ΔΔ[0..31]ΔΔ*) OF CHAR;            (* ASCII partition name *)
  85.         pmParType*:                (*ΔΔPACKEDΔΔ*) ARRAY 32 (*ΔΔ[0..31]ΔΔ*) OF CHAR;            (* ASCII partition type *)
  86.         pmLgDataStart*:            LONGINT;                                (* log. # of partition's 1st data blk *)
  87.         pmDataCnt*:                LONGINT;                                (* # of blks in partition's data area *)
  88.         pmPartStatus*:            LONGINT;                                (* bit field for partition status *)
  89.         pmLgBootStart*:            LONGINT;                                (* log. blk of partition's boot code *)
  90.         pmBootSize*:                LONGINT;                                (* number of bytes in boot code *)
  91.         pmBootAddr*:                LONGINT;                                (* memory load address of boot code *)
  92.         pmBootAddr2*:            LONGINT;                                (* currently unused *)
  93.         pmBootEntry*:            LONGINT;                                (* entry point of boot code *)
  94.         pmBootEntry2*:            LONGINT;                                (* currently unused *)
  95.         pmBootCksum*:            LONGINT;                                (* checksum of boot code *)
  96.         pmProcessor*:            (*ΔΔPACKEDΔΔ*) ARRAY 16 (*ΔΔ[0..15]ΔΔ*) OF CHAR;            (* ASCII for the processor type *)
  97.         pmPad*:                    ARRAY 188 (*ΔΔ[0..187]ΔΔ*) OF INTEGER;                (* 512 bytes long currently unused *)
  98.     END;
  99.  
  100. (* TIB instruction *)
  101.     SCSIInstr* = RECORD
  102.         scOpcode*:                INTEGER;
  103.         scParam1*:                LONGINT;
  104.         scParam2*:                LONGINT;
  105.     END;
  106.  
  107.  
  108. PROCEDURE SCSIReset*(): Types.OSErr;
  109.     (*$IF NOT GENERATINGCFM*)
  110.     INLINE PASCAL $4267, $A815;
  111.     (*$END*)
  112. PROCEDURE SCSIGet*(): Types.OSErr;
  113.     (*$IF NOT GENERATINGCFM*)
  114.     INLINE PASCAL $3F3C, $0001, $A815;
  115.     (*$END*)
  116. PROCEDURE SCSISelect*(targetID: INTEGER): Types.OSErr;
  117.     (*$IF NOT GENERATINGCFM*)
  118.     INLINE PASCAL $3F3C, $0002, $A815;
  119.     (*$END*)
  120. PROCEDURE SCSICmd*(buffer: Types.Ptr; count: INTEGER): Types.OSErr;
  121.     (*$IF NOT GENERATINGCFM*)
  122.     INLINE PASCAL $3F3C, $0003, $A815;
  123.     (*$END*)
  124. PROCEDURE SCSIRead*(tibPtr: Types.Ptr): Types.OSErr;
  125.     (*$IF NOT GENERATINGCFM*)
  126.     INLINE PASCAL $3F3C, $0005, $A815;
  127.     (*$END*)
  128. PROCEDURE SCSIRBlind*(tibPtr: Types.Ptr): Types.OSErr;
  129.     (*$IF NOT GENERATINGCFM*)
  130.     INLINE PASCAL $3F3C, $0008, $A815;
  131.     (*$END*)
  132. PROCEDURE SCSIWrite*(tibPtr: Types.Ptr): Types.OSErr;
  133.     (*$IF NOT GENERATINGCFM*)
  134.     INLINE PASCAL $3F3C, $0006, $A815;
  135.     (*$END*)
  136. PROCEDURE SCSIWBlind*(tibPtr: Types.Ptr): Types.OSErr;
  137.     (*$IF NOT GENERATINGCFM*)
  138.     INLINE PASCAL $3F3C, $0009, $A815;
  139.     (*$END*)
  140. PROCEDURE SCSIComplete*(VAR stat: INTEGER; VAR message: INTEGER; wait: LONGINT): Types.OSErr;
  141.     (*$IF NOT GENERATINGCFM*)
  142.     INLINE PASCAL $3F3C, $0004, $A815;
  143.     (*$END*)
  144. PROCEDURE SCSIStat*(): INTEGER;
  145.     (*$IF NOT GENERATINGCFM*)
  146.     INLINE PASCAL $3F3C, $000A, $A815;
  147.     (*$END*)
  148. PROCEDURE SCSISelAtn*(targetID: INTEGER): Types.OSErr;
  149.     (*$IF NOT GENERATINGCFM*)
  150.     INLINE PASCAL $3F3C, $000B, $A815;
  151.     (*$END*)
  152. PROCEDURE SCSIMsgIn*(VAR message: INTEGER): Types.OSErr;
  153.     (*$IF NOT GENERATINGCFM*)
  154.     INLINE PASCAL $3F3C, $000C, $A815;
  155.     (*$END*)
  156. PROCEDURE SCSIMsgOut*(message: INTEGER): Types.OSErr;
  157.     (*$IF NOT GENERATINGCFM*)
  158.     INLINE PASCAL $3F3C, $000D, $A815;
  159.     (*$END*)
  160. (*——————————————————————— New SCSI Manager Interface ———————————————————————*)
  161.  
  162. CONST
  163.     scsiVERSION*                    = 43;
  164.  
  165. (* SCSI Manager function codes *)
  166.     SCSINop*                        = $00;                            (* Execute nothing                                         *)
  167.     SCSIExecIO*                    = $01;                            (* Execute the specified IO                             *)
  168.     SCSIBusInquiry*                = $03;                            (* Get parameters for entire path of HBAs                 *)
  169.     SCSIReleaseQ*                = $04;                            (* Release the frozen SIM queue for particular LUN         *)
  170.     SCSIAbortCommand*            = $10;                            (* Abort the selected Control Block                      *)
  171.     SCSIResetBus*                = $11;                            (* Reset the SCSI bus                                      *)
  172.     SCSIResetDevice*                = $12;                            (* Reset the SCSI device                                  *)
  173.     SCSITerminateIO*                = $13;                            (* Terminate any pending IO                              *)
  174.     SCSIGetVirtualIDInfo*        = $80;                            (* Find out which bus old AIFF.ID is on                         *)
  175.     SCSILoadDriver*                = $82;                            (* Load a driver for a device ident                     *)
  176.     SCSIOldCall*                    = $84;                            (* XPT->SIM private call for old-API                     *)
  177.     SCSICreateRefNumXref*        = $85;                            (* Register a DeviceIdent to drvr RefNum xref             *)
  178.     SCSILookupRefNumXref*        = $86;                            (* Get DeviceIdent to drvr RefNum xref                     *)
  179.     SCSIRemoveRefNumXref*        = $87;                            (* Remove a DeviceIdent to drvr RefNum xref             *)
  180.     SCSIRegisterWithNewXPT*        = $88;                            (* XPT has changed - SIM needs to re-register itself     *)
  181.     vendorUnique*                = $C0;                            (* 0xC0 thru 0xFF *)
  182.  
  183. (* SCSI Callback Procedure Prototypes* *)
  184. (* SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility *)
  185. TYPE
  186.     SCSICallbackProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (scsiPB: (*ΔΔUNIVΔΔ*) Types.Ptr);
  187.     AENCallbackProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE ;
  188.     SIMInitProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (SIMinfoPtr: Types.Ptr): Types.OSErr;
  189.     SIMActionProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (scsiPB: (*ΔΔUNIVΔΔ*) Types.Ptr; SIMGlobals: Types.Ptr);
  190.     SCSIProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE ;
  191.     SCSIMakeCallbackProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (scsiPB: (*ΔΔUNIVΔΔ*) Types.Ptr);
  192.     SCSIInterruptPollProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (SIMGlobals: Types.Ptr): LONGINT;
  193.     SCSIInterruptProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (SIMGlobals: Types.Ptr): LONGINT;
  194.     SCSICallbackUPP* = Types.UniversalProcPtr;
  195.     AENCallbackUPP* = Types.UniversalProcPtr;
  196.     SIMInitUPP* = Types.UniversalProcPtr;
  197.     SIMActionUPP* = Types.UniversalProcPtr;
  198.     SCSIUPP* = Types.UniversalProcPtr;
  199.     SCSIMakeCallbackUPP* = Types.UniversalProcPtr;
  200.     SCSIInterruptPollUPP* = Types.UniversalProcPtr;
  201.     SCSIInterruptUPP* = Types.UniversalProcPtr;
  202.  
  203. CONST
  204.     uppSCSICallbackProcInfo* = $000000C0; (* PROCEDURE (4 byte param); *)
  205.     uppAENCallbackProcInfo* = $00000001; (* PROCEDURE ; *)
  206.     uppSIMInitProcInfo* = $000000E1; (* PROCEDURE (4 byte param): 2 byte result; *)
  207.     uppSIMActionProcInfo* = $000003C1; (* PROCEDURE (4 byte param, 4 byte param); *)
  208.     uppSCSIProcInfo* = $00000001; (* PROCEDURE ; *)
  209.     uppSCSIMakeCallbackProcInfo* = $000000C1; (* PROCEDURE (4 byte param); *)
  210.     uppSCSIInterruptPollProcInfo* = $000000F1; (* PROCEDURE (4 byte param): 4 byte result; *)
  211.     uppSCSIInterruptProcInfo* = $000000F1; (* PROCEDURE (4 byte param): 4 byte result; *)
  212.  
  213. PROCEDURE NewSCSICallbackProc*(userRoutine: SCSICallbackProcPtr): SCSICallbackUPP;
  214.     (*$IF NOT GENERATINGCFM *)
  215.     INLINE PASCAL $2E9F;
  216.     (*$END*)
  217.  
  218. PROCEDURE NewAENCallbackProc*(userRoutine: AENCallbackProcPtr): AENCallbackUPP;
  219.     (*$IF NOT GENERATINGCFM *)
  220.     INLINE PASCAL $2E9F;
  221.     (*$END*)
  222.  
  223. PROCEDURE NewSIMInitProc*(userRoutine: SIMInitProcPtr): SIMInitUPP;
  224.     (*$IF NOT GENERATINGCFM *)
  225.     INLINE PASCAL $2E9F;
  226.     (*$END*)
  227.  
  228. PROCEDURE NewSIMActionProc*(userRoutine: SIMActionProcPtr): SIMActionUPP;
  229.     (*$IF NOT GENERATINGCFM *)
  230.     INLINE PASCAL $2E9F;
  231.     (*$END*)
  232.  
  233. PROCEDURE NewSCSIProc*(userRoutine: SCSIProcPtr): SCSIUPP;
  234.     (*$IF NOT GENERATINGCFM *)
  235.     INLINE PASCAL $2E9F;
  236.     (*$END*)
  237.  
  238. PROCEDURE NewSCSIMakeCallbackProc*(userRoutine: SCSIMakeCallbackProcPtr): SCSIMakeCallbackUPP;
  239.     (*$IF NOT GENERATINGCFM *)
  240.     INLINE PASCAL $2E9F;
  241.     (*$END*)
  242.  
  243. PROCEDURE NewSCSIInterruptPollProc*(userRoutine: SCSIInterruptPollProcPtr): SCSIInterruptPollUPP;
  244.     (*$IF NOT GENERATINGCFM *)
  245.     INLINE PASCAL $2E9F;
  246.     (*$END*)
  247.  
  248. PROCEDURE NewSCSIInterruptProc*(userRoutine: SCSIInterruptProcPtr): SCSIInterruptUPP;
  249.     (*$IF NOT GENERATINGCFM *)
  250.     INLINE PASCAL $2E9F;
  251.     (*$END*)
  252.  
  253. PROCEDURE CallSCSICallbackProc*(scsiPB: (*ΔΔUNIVΔΔ*) Types.Ptr; userRoutine: SCSICallbackUPP);
  254.     (*$IF NOT GENERATINGCFM*)
  255.     INLINE PASCAL $205F, $4E90;
  256.     (*$END*)
  257.  
  258. PROCEDURE CallAENCallbackProc*(userRoutine: AENCallbackUPP);
  259.     (*$IF NOT GENERATINGCFM*)
  260.     INLINE PASCAL $205F, $4E90;
  261.     (*$END*)
  262.  
  263. PROCEDURE CallSIMInitProc*(SIMinfoPtr: Types.Ptr; userRoutine: SIMInitUPP): Types.OSErr;
  264.     (*$IF NOT GENERATINGCFM*)
  265.     INLINE PASCAL $205F, $4E90;
  266.     (*$END*)
  267.  
  268. PROCEDURE CallSIMActionProc*(scsiPB: (*ΔΔUNIVΔΔ*) Types.Ptr; SIMGlobals: Types.Ptr; userRoutine: SIMActionUPP);
  269.     (*$IF NOT GENERATINGCFM*)
  270.     INLINE PASCAL $205F, $4E90;
  271.     (*$END*)
  272.  
  273. PROCEDURE CallSCSIProc*(userRoutine: SCSIUPP);
  274.     (*$IF NOT GENERATINGCFM*)
  275.     INLINE PASCAL $205F, $4E90;
  276.     (*$END*)
  277.  
  278. PROCEDURE CallSCSIMakeCallbackProc*(scsiPB: (*ΔΔUNIVΔΔ*) Types.Ptr; userRoutine: SCSIMakeCallbackUPP);
  279.     (*$IF NOT GENERATINGCFM*)
  280.     INLINE PASCAL $205F, $4E90;
  281.     (*$END*)
  282.  
  283. PROCEDURE CallSCSIInterruptPollProc*(SIMGlobals: Types.Ptr; userRoutine: SCSIInterruptPollUPP): LONGINT;
  284.     (*$IF NOT GENERATINGCFM*)
  285.     INLINE PASCAL $205F, $4E90;
  286.     (*$END*)
  287.  
  288. PROCEDURE CallSCSIInterruptProc*(SIMGlobals: Types.Ptr; userRoutine: SCSIInterruptUPP): LONGINT;
  289.     (*$IF NOT GENERATINGCFM*)
  290.     INLINE PASCAL $205F, $4E90;
  291.     (*$END*)
  292.  
  293. CONST
  294.     handshakeDataLength*            = 8;                            (* Handshake data length *)
  295.     maxCDBLength*                = 16;                            (* Space for the CDB bytes/pointer *)
  296.     vendorIDLength*                = 16;                            (* ASCII string len for Vendor AIFF.ID  *)
  297.  
  298. (* Define DeviceIdent structure *)
  299.  
  300. TYPE
  301.     DeviceIdent* = (*ΔΔPACKEDΔΔ*) RECORD
  302.         diReserved*:                Types.UInt8;                                    (* reserved                 *)
  303.         bus*:                    Types.UInt8;                                    (* SCSI - Bus Number        *)
  304.         targetID*:                Types.UInt8;                                    (* SCSI - Target SCSI AIFF.ID    *)
  305.         LUN*:                    Types.UInt8;                                    (* SCSI - LUN                  *)
  306.     END;
  307.  
  308. (* Command Descriptor Block structure *)
  309.     CDB* = ARRAY (*ΔΔ[0..*)maxCDBLength(*ΔΔ -1]ΔΔ*) OF Types.UInt8;
  310.  
  311.     SGRecord* = RECORD
  312.         SGAddr*:                    Types.Ptr;
  313.         SGCount*:                Types.UInt32;
  314.     END;
  315.  
  316. (* SCSI Phases (used by SIMs to support the Original SCSI Manager *)
  317.  
  318. CONST
  319.     kDataOutPhase*                = 0;                            (* Encoded MSG, C/D, I/O bits *)
  320.     kDataInPhase*                = 1;
  321.     kCommandPhase*                = 2;
  322.     kStatusPhase*                = 3;
  323.     kPhaseIllegal0*                = 4;
  324.     kPhaseIllegal1*                = 5;
  325.     kMessageOutPhase*            = 6;
  326.     kMessageInPhase*                = 7;
  327.     kBusFreePhase*                = 8;                            (* Additional Phases *)
  328.     kArbitratePhase*                = 9;
  329.     kSelectPhase*                = 10;
  330.     kMessageInPhaseNACK*            = 11;                            (* Message In Phase with ACK hanging on the bus *)
  331.  
  332.  
  333. TYPE
  334.     SCSIHdrPtr* = POINTER TO SCSIHdr;
  335.     SCSIHdr* = RECORD
  336.         qLink*:                    SCSIHdrPtr (*ΔΔ POINTER TO SCSIHdr*);
  337.         scsiReserved1*:            INTEGER;
  338.         scsiPBLength*:            Types.UInt16;
  339.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  340.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  341.         scsiResult*:                Types.OSErr;
  342.         scsiDevice*:                DeviceIdent;
  343.         scsiCompletion*:            SCSICallbackUPP;
  344.         scsiFlags*:                Types.UInt32;
  345.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  346.         scsiXPTprivate*:            Types.Ptr;
  347.         scsiReserved3*:            LONGINT;
  348.     END;
  349.  
  350.     SCSI_PB* = RECORD
  351.         qLink*:                    POINTER TO SCSIHdr;
  352.         scsiReserved1*:            INTEGER;
  353.         scsiPBLength*:            Types.UInt16;
  354.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  355.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  356.         scsiResult*:                Types.OSErr;
  357.         scsiDevice*:                DeviceIdent;
  358.         scsiCompletion*:            SCSICallbackUPP;
  359.         scsiFlags*:                Types.UInt32;
  360.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  361.         scsiXPTprivate*:            Types.Ptr;
  362.         scsiReserved3*:            LONGINT;
  363.     END;
  364.  
  365.     SCSI_IOPtr* = POINTER TO SCSI_IO;
  366.     SCSI_IO* = RECORD
  367.         qLink*:                    POINTER TO SCSIHdr;
  368.         scsiReserved1*:            INTEGER;
  369.         scsiPBLength*:            Types.UInt16;
  370.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  371.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  372.         scsiResult*:                Types.OSErr;
  373.         scsiDevice*:                DeviceIdent;
  374.         scsiCompletion*:            SCSICallbackUPP;
  375.         scsiFlags*:                Types.UInt32;
  376.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  377.         scsiXPTprivate*:            Types.Ptr;
  378.         scsiReserved3*:            LONGINT;
  379.         scsiResultFlags*:        Types.UInt16;
  380.         scsiReserved3pt5*:        Types.UInt16;
  381.         scsiDataPtr*:            SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  382.         scsiDataLength*:            Types.UInt32;
  383.         scsiSensePtr*:            SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  384.         scsiSenseLength*:        Types.SInt8; (* UInt8 *)
  385.         scsiCDBLength*:            Types.SInt8; (* UInt8 *)
  386.         scsiSGListCount*:        Types.UInt16;
  387.         scsiReserved4*:            Types.UInt32;
  388.         scsiSCSIstatus*:            Types.SInt8; (* UInt8 *)
  389.         scsiSenseResidual*:        Types.SInt8;
  390.         scsiReserved5*:            Types.UInt16;
  391.         scsiDataResidual*:        LONGINT;
  392.         scsiCDB*:                CDB;
  393.         scsiTimeout*:            LONGINT;
  394.         scsiReserved5pt5*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  395.         scsiReserved5pt6*:        Types.UInt16;
  396.         scsiIOFlags*:            Types.UInt16;
  397.         scsiTagAction*:            Types.SInt8; (* UInt8 *)
  398.         scsiReserved6*:            Types.SInt8; (* UInt8 *)
  399.         scsiReserved7*:            Types.UInt16;
  400.         scsiSelectTimeout*:        Types.UInt16;
  401.         scsiDataType*:            Types.SInt8; (* UInt8 *)
  402.         scsiTransferType*:        Types.SInt8; (* UInt8 *)
  403.         scsiReserved8*:            Types.UInt32;
  404.         scsiReserved9*:            Types.UInt32;
  405.         scsiHandshake*:            ARRAY (*ΔΔ[0..*)handshakeDataLength(*ΔΔ -1]ΔΔ*) OF Types.UInt16;
  406.         scsiReserved10*:            Types.UInt32;
  407.         scsiReserved11*:            Types.UInt32;
  408.         scsiCommandLink*:        SCSI_IOPtr (*ΔΔ POINTER TO SCSI_IO*);
  409.         scsiSIMpublics*:            ARRAY 8 (*ΔΔ[0..7]ΔΔ*) OF Types.SInt8; (* UInt8 *)
  410.         scsiAppleReserved6*:        ARRAY 8 (*ΔΔ[0..7]ΔΔ*) OF Types.SInt8; (* UInt8 *)
  411.         scsiCurrentPhase*:        Types.UInt16;
  412.         scsiSelector*:            INTEGER;
  413.         scsiOldCallResult*:        Types.OSErr;
  414.         scsiSCSImessage*:        Types.SInt8; (* UInt8 *)
  415.         XPTprivateFlags*:        Types.SInt8; (* UInt8 *)
  416.         XPTextras*:                ARRAY 12 (*ΔΔ[0..11]ΔΔ*) OF Types.SInt8; (* UInt8 *)
  417.     END;
  418.  
  419.     SCSIExecIOPB* = SCSI_IO;
  420.  
  421. (* Bus inquiry PB *)
  422.     SCSIBusInquiryPB* = RECORD
  423.         qLink*:                    POINTER TO SCSIHdr;
  424.         scsiReserved1*:            INTEGER;
  425.         scsiPBLength*:            Types.UInt16;
  426.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  427.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  428.         scsiResult*:                Types.OSErr;
  429.         scsiDevice*:                DeviceIdent;
  430.         scsiCompletion*:            SCSICallbackUPP;
  431.         scsiFlags*:                Types.UInt32;
  432.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  433.         scsiXPTprivate*:            Types.Ptr;
  434.         scsiReserved3*:            LONGINT;
  435.         scsiEngineCount*:        Types.UInt16;                                    (* <- Number of engines on HBA                         *)
  436.         scsiMaxTransferType*:    Types.UInt16;                                    (* <- Number of transfer types for this HBA            *)
  437.         scsiDataTypes*:            Types.UInt32;                                    (* <- which data types are supported by this SIM     *)
  438.         scsiIOpbSize*:            Types.UInt16;                                    (* <- Memory.Size of SCSI_IO PB for this SIM/HBA             *)
  439.         scsiMaxIOpbSize*:        Types.UInt16;                                    (* <- Memory.Size of max SCSI_IO PB for all SIM/HBAs         *)
  440.         scsiFeatureFlags*:        Types.UInt32;                                    (* <- Supported features flags field                 *)
  441.         scsiVersionNumber*:        Types.SInt8; (* UInt8 *)                        (* <- Version number for the SIM/HBA                 *)
  442.         scsiHBAInquiry*:            Types.SInt8; (* UInt8 *)                        (* <- Mimic of INQ byte 7 for the HBA                 *)
  443.         scsiTargetModeFlags*:    Types.SInt8; (* UInt8 *)                        (* <- Flags for target mode support                 *)
  444.         scsiScanFlags*:            Types.SInt8; (* UInt8 *)                        (* <- Scan related feature flags                     *)
  445.         scsiSIMPrivatesPtr*:        Types.UInt32;                                    (* <- Types.Ptr to SIM private data area                     *)
  446.         scsiSIMPrivatesSize*:    Types.UInt32;                                    (* <- Memory.Size of SIM private data area                 *)
  447.         scsiAsyncFlags*:            Types.UInt32;                                    (* <- Event cap. for Async Callback                 *)
  448.         scsiHiBusID*:            Types.SInt8; (* UInt8 *)                        (* <- Highest path AIFF.ID in the subsystem              *)
  449.         scsiInitiatorID*:        Types.SInt8; (* UInt8 *)                        (* <- AIFF.ID of the HBA on the SCSI bus                 *)
  450.         scsiBIReserved0*:        Types.UInt16;                                    (*                                                    *)
  451.         scsiBIReserved1*:        Types.UInt32;                                    (* <-                                                  *)
  452.         scsiFlagsSupported*:        Types.UInt32;                                    (* <- which scsiFlags are supported                 *)
  453.         scsiIOFlagsSupported*:    Types.UInt16;                                    (* <- which scsiIOFlags are supported                 *)
  454.         scsiWeirdStuff*:            Types.UInt16;                                    (* <-                                                 *)
  455.         scsiMaxTarget*:            Types.UInt16;                                    (* <- maximum Target number supported                 *)
  456.         scsiMaxLUN*:                Types.UInt16;                                    (* <- maximum Logical Unit number supported         *)
  457.         scsiSIMVendor*:            (*ΔΔPACKEDΔΔ*) ARRAY (*ΔΔ[0..*)vendorIDLength(*ΔΔ -1]ΔΔ*) OF CHAR; (* <- Vendor AIFF.ID of SIM (or XPT if bus<FF)         *)
  458.         scsiHBAVendor*:            (*ΔΔPACKEDΔΔ*) ARRAY (*ΔΔ[0..*)vendorIDLength(*ΔΔ -1]ΔΔ*) OF CHAR; (* <- Vendor AIFF.ID of the HBA                         *)
  459.         scsiControllerFamily*:    (*ΔΔPACKEDΔΔ*) ARRAY (*ΔΔ[0..*)vendorIDLength(*ΔΔ -1]ΔΔ*) OF CHAR; (* <- Family of SCSI Controller                 *)
  460.         scsiControllerType*:        (*ΔΔPACKEDΔΔ*) ARRAY (*ΔΔ[0..*)vendorIDLength(*ΔΔ -1]ΔΔ*) OF CHAR; (* <- Specific Model of SCSI Controller used     *)
  461.         scsiXPTversion*:            (*ΔΔPACKEDΔΔ*) ARRAY 4 (*ΔΔ[0..3]ΔΔ*) OF CHAR;            (* <- version number of XPT                         *)
  462.         scsiSIMversion*:            (*ΔΔPACKEDΔΔ*) ARRAY 4 (*ΔΔ[0..3]ΔΔ*) OF CHAR;            (* <- version number of SIM                         *)
  463.         scsiHBAversion*:            (*ΔΔPACKEDΔΔ*) ARRAY 4 (*ΔΔ[0..3]ΔΔ*) OF CHAR;            (* <- version number of HBA                         *)
  464.         scsiHBAslotType*:        Types.SInt8; (* UInt8 *)                        (* <- type of "slot" that this HBA is in            *)
  465.         scsiHBAslotNumber*:        Types.SInt8; (* UInt8 *)                        (* <- slot number of this HBA                         *)
  466.         scsiSIMsRsrcID*:            Types.UInt16;                                    (* <- resource AIFF.ID of this SIM                         *)
  467.         scsiBIReserved3*:        Types.UInt16;                                    (* <-                                                 *)
  468.         scsiAdditionalLength*:    Types.UInt16;                                    (* <- additional BusInquiry PB len                    *)
  469.     END;
  470.  
  471. (* Abort SIM Request PB *)
  472.     SCSIAbortCommandPB* = RECORD
  473.         qLink*:                    POINTER TO SCSIHdr;
  474.         scsiReserved1*:            INTEGER;
  475.         scsiPBLength*:            Types.UInt16;
  476.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  477.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  478.         scsiResult*:                Types.OSErr;
  479.         scsiDevice*:                DeviceIdent;
  480.         scsiCompletion*:            SCSICallbackUPP;
  481.         scsiFlags*:                Types.UInt32;
  482.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  483.         scsiXPTprivate*:            Types.Ptr;
  484.         scsiReserved3*:            LONGINT;
  485.         scsiIOptr*:                SYSTEM.PTR (*ΔΔ POINTER TO SCSI_IO*);                                (* Pointer to the PB to abort                        *)
  486.     END;
  487.  
  488. (* Terminate I/O Process Request PB *)
  489.     SCSITerminateIOPB* = RECORD
  490.         qLink*:                    POINTER TO SCSIHdr;
  491.         scsiReserved1*:            INTEGER;
  492.         scsiPBLength*:            Types.UInt16;
  493.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  494.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  495.         scsiResult*:                Types.OSErr;
  496.         scsiDevice*:                DeviceIdent;
  497.         scsiCompletion*:            SCSICallbackUPP;
  498.         scsiFlags*:                Types.UInt32;
  499.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  500.         scsiXPTprivate*:            Types.Ptr;
  501.         scsiReserved3*:            LONGINT;
  502.         scsiIOptr*:                POINTER TO SCSI_IO;                                (* Pointer to the PB to terminate                     *)
  503.     END;
  504.  
  505. (* Reset SCSI Bus PB *)
  506.     SCSIResetBusPB* = RECORD
  507.         qLink*:                    POINTER TO SCSIHdr;
  508.         scsiReserved1*:            INTEGER;
  509.         scsiPBLength*:            Types.UInt16;
  510.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  511.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  512.         scsiResult*:                Types.OSErr;
  513.         scsiDevice*:                DeviceIdent;
  514.         scsiCompletion*:            SCSICallbackUPP;
  515.         scsiFlags*:                Types.UInt32;
  516.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  517.         scsiXPTprivate*:            Types.Ptr;
  518.         scsiReserved3*:            LONGINT;
  519.     END;
  520.  
  521. (* Reset SCSI Device PB *)
  522.     SCSIResetDevicePB* = RECORD
  523.         qLink*:                    POINTER TO SCSIHdr;
  524.         scsiReserved1*:            INTEGER;
  525.         scsiPBLength*:            Types.UInt16;
  526.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  527.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  528.         scsiResult*:                Types.OSErr;
  529.         scsiDevice*:                DeviceIdent;
  530.         scsiCompletion*:            SCSICallbackUPP;
  531.         scsiFlags*:                Types.UInt32;
  532.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  533.         scsiXPTprivate*:            Types.Ptr;
  534.         scsiReserved3*:            LONGINT;
  535.     END;
  536.  
  537. (* Release SIM Queue PB *)
  538.     SCSIReleaseQPB* = RECORD
  539.         qLink*:                    POINTER TO SCSIHdr;
  540.         scsiReserved1*:            INTEGER;
  541.         scsiPBLength*:            Types.UInt16;
  542.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  543.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  544.         scsiResult*:                Types.OSErr;
  545.         scsiDevice*:                DeviceIdent;
  546.         scsiCompletion*:            SCSICallbackUPP;
  547.         scsiFlags*:                Types.UInt32;
  548.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  549.         scsiXPTprivate*:            Types.Ptr;
  550.         scsiReserved3*:            LONGINT;
  551.     END;
  552.  
  553. (* SCSI Get Virtual AIFF.ID Info PB *)
  554.     SCSIGetVirtualIDInfoPB* = RECORD
  555.         qLink*:                    POINTER TO SCSIHdr;
  556.         scsiReserved1*:            INTEGER;
  557.         scsiPBLength*:            Types.UInt16;
  558.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  559.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  560.         scsiResult*:                Types.OSErr;
  561.         scsiDevice*:                DeviceIdent;
  562.         scsiCompletion*:            SCSICallbackUPP;
  563.         scsiFlags*:                Types.UInt32;
  564.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  565.         scsiXPTprivate*:            Types.Ptr;
  566.         scsiReserved3*:            LONGINT;
  567.         scsiOldCallID*:            Types.UInt16;                                    (* -> SCSI AIFF.ID of device in question             *)
  568.         scsiExists*:                BOOLEAN;                                (* <- true if device exists                     *)
  569.     END;
  570.  
  571. (* Create/Lookup/Remove RefNum for Device PB *)
  572.     SCSIDriverPB* = RECORD
  573.         qLink*:                    POINTER TO SCSIHdr;
  574.         scsiReserved1*:            INTEGER;
  575.         scsiPBLength*:            Types.UInt16;
  576.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  577.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  578.         scsiResult*:                Types.OSErr;
  579.         scsiDevice*:                DeviceIdent;
  580.         scsiCompletion*:            SCSICallbackUPP;
  581.         scsiFlags*:                Types.UInt32;
  582.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  583.         scsiXPTprivate*:            Types.Ptr;
  584.         scsiReserved3*:            LONGINT;
  585.         scsiDriver*:                INTEGER;                                (* -> DriverRefNum, For SetDriver, <- For GetNextDriver *)
  586.         scsiDriverFlags*:        Types.UInt16;                                    (* <> Details of driver/device                     *)
  587.         scsiNextDevice*:            DeviceIdent;                            (* <- DeviceIdent of the NEXT Item in the list  *)
  588.     END;
  589.  
  590. (* Load Driver PB *)
  591.     SCSILoadDriverPB* = RECORD
  592.         qLink*:                    POINTER TO SCSIHdr;
  593.         scsiReserved1*:            INTEGER;
  594.         scsiPBLength*:            Types.UInt16;
  595.         scsiFunctionCode*:        Types.SInt8; (* UInt8 *)
  596.         scsiReserved2*:            Types.SInt8; (* UInt8 *)
  597.         scsiResult*:                Types.OSErr;
  598.         scsiDevice*:                DeviceIdent;
  599.         scsiCompletion*:            SCSICallbackUPP;
  600.         scsiFlags*:                Types.UInt32;
  601.         scsiDriverStorage*:        SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);
  602.         scsiXPTprivate*:            Types.Ptr;
  603.         scsiReserved3*:            LONGINT;
  604.         scsiLoadedRefNum*:        INTEGER;                                (* <- SIM returns refnum of driver                     *)
  605.         scsiDiskLoadFailed*:        BOOLEAN;                                (* -> if true, indicates call after failure to load *)
  606.     END;
  607.  
  608. (* Defines for the scsiTransferType field *)
  609.  
  610. CONST
  611.     scsiTransferBlind*            = 0;
  612.     scsiTransferPolled*            = 1;
  613.  
  614. (* Defines for the scsiDataType field *)
  615.     scsiDataBuffer*                = 0;                            (* single contiguous buffer supplied                  *)
  616.     scsiDataTIB*                    = 1;                            (* TIB supplied (ptr in scsiDataPtr)                 *)
  617.     scsiDataSG*                    = 2;                            (* scatter/gather list supplied                      *)
  618.  
  619. (* Defines for the SCSIMgr scsiResult field in the PB header. *)
  620. (*  $E100 thru  E1FF *)
  621. (* -$1EFF thru -1E00 *)
  622. (* -#7935 thru -7681  *)
  623. (** = 0xE100 *)
  624.     scsiErrorBase*                = -7936;
  625.  
  626.     scsiRequestInProgress*        = 1;                            (* 1*     = PB request is in progress             *)
  627. (* Execution failed  00-2F *)
  628.     scsiRequestAborted*            = scsiErrorBase + 2;            (* -7934* = PB request aborted by the host         *)
  629.     scsiUnableToAbort*            = scsiErrorBase + 3;            (* -7933* = Unable to Abort PB request             *)
  630.     scsiNonZeroStatus*            = scsiErrorBase + 4;            (* -7932* = PB request completed with an err     *)
  631.     scsiUnused05*                = scsiErrorBase + 5;            (* -7931* =                                      *)
  632.     scsiUnused06*                = scsiErrorBase + 6;            (* -7930* =                                      *)
  633.     scsiUnused07*                = scsiErrorBase + 7;            (* -7929* =                                      *)
  634.     scsiUnused08*                = scsiErrorBase + 8;            (* -7928* =                                      *)
  635.     scsiUnableToTerminate*        = scsiErrorBase + 9;            (* -7927* = Unable to Terminate I/O PB req         *)
  636.     scsiSelectTimeout*            = scsiErrorBase + 10;            (* -7926* = Target selection timeout             *)
  637.     scsiCommandTimeout*            = scsiErrorBase + 11;            (* -7925* = Command timeout                      *)
  638.     scsiIdentifyMessageRejected*    = scsiErrorBase + 12;            (* -7924* =                                      *)
  639.     scsiMessageRejectReceived*    = scsiErrorBase + 13;            (* -7923* = Message reject received                 *)
  640.     scsiSCSIBusReset*            = scsiErrorBase + 14;            (* -7922* = SCSI bus reset sent/received         *)
  641.     scsiParityError*                = scsiErrorBase + 15;            (* -7921* = Uncorrectable parity error occured     *)
  642.     scsiAutosenseFailed*            = scsiErrorBase + 16;            (* -7920* = Autosense*: Request sense cmd fail     *)
  643.     scsiUnused11*                = scsiErrorBase + 17;            (* -7919* =                                      *)
  644.     scsiDataRunError*            = scsiErrorBase + 18;            (* -7918* = Data overrun/underrun error          *)
  645.     scsiUnexpectedBusFree*        = scsiErrorBase + 19;            (* -7917* = Unexpected BUS free                     *)
  646.     scsiSequenceFailed*            = scsiErrorBase + 20;            (* -7916* = Target bus phase sequence failure     *)
  647.     scsiWrongDirection*            = scsiErrorBase + 21;            (* -7915* = Data phase was in wrong direction     *)
  648.     scsiUnused16*                = scsiErrorBase + 22;            (* -7914* =                                      *)
  649.     scsiBDRsent*                    = scsiErrorBase + 23;            (* -7913* = A SCSI BDR msg was sent to target     *)
  650.     scsiTerminated*                = scsiErrorBase + 24;            (* -7912* = PB request terminated by the host     *)
  651.     scsiNoNexus*                    = scsiErrorBase + 25;            (* -7911* = Nexus is not established             *)
  652.     scsiCDBReceived*                = scsiErrorBase + 26;            (* -7910* = The SCSI CDB has been received         *)
  653. (* Couldn't begin execution  30-3F *)
  654.     scsiTooManyBuses*            = scsiErrorBase + 48;            (* -7888* = Register failed because we're full    *)
  655.     scsiBusy*                    = scsiErrorBase + 49;            (* -7887* = SCSI subsystem is busy                 *)
  656.     scsiProvideFail*                = scsiErrorBase + 50;            (* -7886* = Unable to provide requ. capability    *)
  657.     scsiDeviceNotThere*            = scsiErrorBase + 51;            (* -7885* = SCSI device not installed/there      *)
  658.     scsiNoHBA*                    = scsiErrorBase + 52;            (* -7884* = No HBA detected Error                 *)
  659.     scsiDeviceConflict*            = scsiErrorBase + 53;            (* -7883* = sorry, max 1 refNum per DeviceIdent     *)
  660.     scsiNoSuchXref*                = scsiErrorBase + 54;            (* -7882* = no such RefNum xref                     *)
  661.     scsiQLinkInvalid*            = scsiErrorBase + 55;            (* -7881* = pre-linked PBs not supported            
  662.                                                                    (The QLink field was nonzero)        *)
  663. (* Parameter errors  40-7F *)
  664.     scsiPBLengthError*            = scsiErrorBase + 64;            (* -7872* = (scsiPBLength is insuf'ct/invalid     *)
  665.     scsiFunctionNotAvailable*    = scsiErrorBase + 65;            (* -7871* = The requ. func is not available      *)
  666.     scsiRequestInvalid*            = scsiErrorBase + 66;            (* -7870* = PB request is invalid                 *)
  667.     scsiBusInvalid*                = scsiErrorBase + 67;            (* -7869* = Bus AIFF.ID supplied is invalid              *)
  668.     scsiTIDInvalid*                = scsiErrorBase + 68;            (* -7868* = Target AIFF.ID supplied is invalid         *)
  669.     scsiLUNInvalid*                = scsiErrorBase + 69;            (* -7867* = LUN supplied is invalid              *)
  670.     scsiIDInvalid*                = scsiErrorBase + 70;            (* -7866* = The initiator AIFF.ID is invalid          *)
  671.     scsiDataTypeInvalid*            = scsiErrorBase + 71;            (* -7865* = scsiDataType requested not supported *)
  672.     scsiTransferTypeInvalid*        = scsiErrorBase + 72;            (* -7864* = scsiTransferType field is too high     *)
  673.     scsiCDBLengthInvalid*        = scsiErrorBase + 73;            (* -7863* = scsiCDBLength field is too big         *)
  674.  
  675.     scsiExecutionErrors*            = scsiErrorBase;
  676.     scsiNotExecutedErrors*        = scsiTooManyBuses;
  677.     scsiParameterErrors*            = scsiPBLengthError;
  678.  
  679. (* Defines for the scsiResultFlags field *)
  680.     scsiSIMQFrozen*                = $0001;                        (* The SIM queue is frozen w/this err            *)
  681.     scsiAutosenseValid*            = $0002;                        (* Autosense data valid for target              *)
  682.     scsiBusNotFree*                = $0004;                        (* At time of callback, SCSI bus is not free    *)
  683.  
  684. (* Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function *)
  685.     kbSCSIDisableAutosense*        = 29;                            (* Disable auto sense feature                     *)
  686.     kbSCSIFlagReservedA*            = 28;                            (*                                              *)
  687.     kbSCSIFlagReserved0*            = 27;                            (*                                              *)
  688.     kbSCSICDBLinked*                = 26;                            (* The PB contains a linked CDB                    *)
  689.     kbSCSIQEnable*                = 25;                            (* Target queue actions are enabled                *)
  690.     kbSCSICDBIsPointer*            = 24;                            (* The CDB field contains a pointer                *)
  691.     kbSCSIFlagReserved1*            = 23;                            (*                                                 *)
  692.     kbSCSIInitiateSyncData*        = 22;                            (* Attempt Sync data xfer and SDTR                *)
  693.     kbSCSIDisableSyncData*        = 21;                            (* Disable sync, go to async                    *)
  694.     kbSCSISIMQHead*                = 20;                            (* Place PB at the head of SIM Q                *)
  695.     kbSCSISIMQFreeze*            = 19;                            (* Return the SIM Q to frozen state                *)
  696.     kbSCSISIMQNoFreeze*            = 18;                            (* Disallow SIM Q freezing                        *)
  697.     kbSCSIDoDisconnect*            = 17;                            (* Definitely do disconnect                        *)
  698.     kbSCSIDontDisconnect*        = 16;                            (* Definitely don't disconnect                    *)
  699.     kbSCSIDataReadyForDMA*        = 15;                            (* Data buffer(s) are ready for DMA                *)
  700.     kbSCSIFlagReserved3*            = 14;                            (*                                                 *)
  701.     kbSCSIDataPhysical*            = 13;                            (* SG/Buffer data ptrs are physical                *)
  702.     kbSCSISensePhysical*            = 12;                            (* Autosense buffer ptr is physical                *)
  703.     kbSCSIFlagReserved5*            = 11;                            (*                                                 *)
  704.     kbSCSIFlagReserved6*            = 10;                            (*                                                 *)
  705.     kbSCSIFlagReserved7*            = 9;                            (*                                                 *)
  706.     kbSCSIFlagReserved8*            = 8;                            (*                                                 *)
  707.     kbSCSIDataBufferValid*        = 7;                            (* Data buffer valid                            *)
  708.     kbSCSIStatusBufferValid*        = 6;                            (* Status buffer valid                             *)
  709.     kbSCSIMessageBufferValid*    = 5;                            (* Message buffer valid                            *)
  710.     kbSCSIFlagReserved9*            = 4;                            (*                                              *)
  711.  
  712. (* Defines for the bit masks of the scsiFlags field *)
  713.     scsiDirectionMask*            = $C0000000;                    (* Data direction mask                        *)
  714.     scsiDirectionNone*            = $C0000000;                    (* Data direction (11: no data)                *)
  715.     scsiDirectionReserved*        = $00000000;                    (* Data direction (00: reserved)            *)
  716.     scsiDirectionOut*            = $80000000;                    (* Data direction (10: DATA OUT)            *)
  717.     scsiDirectionIn*                = $40000000;                    (* Data direction (01: DATA IN)                *)
  718.     scsiDisableAutosense*        = $20000000;                    (* Disable auto sense feature                *)
  719.     scsiFlagReservedA*            = $10000000;                    (*                                             *)
  720.     scsiFlagReserved0*            = $08000000;                    (*                                             *)
  721.     scsiCDBLinked*                = $04000000;                    (* The PB contains a linked CDB                *)
  722.     scsiQEnable*                    = $02000000;                    (* Target queue actions are enabled            *)
  723.     scsiCDBIsPointer*            = $01000000;                    (* The CDB field contains a pointer            *)
  724.     scsiFlagReserved1*            = $00800000;                    (*                                             *)
  725.     scsiInitiateSyncData*        = $00400000;                    (* Attempt Sync data xfer and SDTR            *)
  726.     scsiDisableSyncData*            = $00200000;                    (* Disable sync, go to async                *)
  727.     scsiSIMQHead*                = $00100000;                    (* Place PB at the head of SIM Q            *)
  728.     scsiSIMQFreeze*                = $00080000;                    (* Return the SIM Q to frozen state            *)
  729.     scsiSIMQNoFreeze*            = $00040000;                    (* Disallow SIM Q freezing                    *)
  730.     scsiDoDisconnect*            = $00020000;                    (* Definitely do disconnect                    *)
  731.     scsiDontDisconnect*            = $00010000;                    (* Definitely don't disconnect                *)
  732.     scsiDataReadyForDMA*            = $00008000;                    (* Data buffer(s) are ready for DMA            *)
  733.     scsiFlagReserved3*            = $00004000;                    (*  *)
  734.     scsiDataPhysical*            = $00002000;                    (* SG/Buffer data ptrs are physical            *)
  735.     scsiSensePhysical*            = $00001000;                    (* Autosense buffer ptr is physical            *)
  736.     scsiFlagReserved5*            = $00000800;                    (*                                          *)
  737.     scsiFlagReserved6*            = $00000400;                    (*                                             *)
  738.     scsiFlagReserved7*            = $00000200;                    (*                                             *)
  739.     scsiFlagReserved8*            = $00000100;                    (*                                             *)
  740.  
  741. (* bit masks for the scsiIOFlags field in SCSIExecIOPB *)
  742.     scsiNoParityCheck*            = $0002;                        (* disable parity checking                             *)
  743.     scsiDisableSelectWAtn*        = $0004;                        (* disable select w/Atn                              *)
  744.     scsiSavePtrOnDisconnect*        = $0008;                        (* do SaveDataPointer upon Disconnect msg             *)
  745.     scsiNoBucketIn*                = $0010;                        (* don’t bit bucket in during this I/O                 *)
  746.     scsiNoBucketOut*                = $0020;                        (* don’t bit bucket out during this I/O             *)
  747.     scsiDisableWide*                = $0040;                        (* disable wide transfer negotiation                 *)
  748.     scsiInitiateWide*            = $0080;                        (* initiate wide transfer negotiation                 *)
  749.     scsiRenegotiateSense*        = $0100;                        (* renegotiate sync/wide before issuing autosense     *)
  750.     scsiDisableDiscipline*        = $0200;                        (* disable parameter checking on SCSIExecIO calls    *)
  751.     scsiIOFlagReserved0080*        = $0080;                        (*                                                  *)
  752.     scsiIOFlagReserved8000*        = $8000;                        (*                                                     *)
  753.  
  754. (* Defines for the SIM/HBA queue actions.  These values are used in the *)
  755. (* SCSIExecIOPB, for the queue action field. [These values should match the *)
  756. (* defines from some other include file for the SCSI message phases.  We may *)
  757. (* not need these definitions here. ] *)
  758.     scsiSimpleQTag*                = $20;                            (* Tag for a simple queue                                 *)
  759.     scsiHeadQTag*                = $21;                            (* Tag for head of queue                                  *)
  760.     scsiOrderedQTag*                = $22;                            (* Tag for ordered queue                                 *)
  761.  
  762. (* Defines for the Bus Inquiry PB fields. *)
  763. (* scsiHBAInquiry field bits *)
  764.     scsiBusMDP*                    = $80;                            (* Supports Modify Data Pointer message                        *)
  765.     scsiBusWide32*                = $40;                            (* Supports 32 bit wide SCSI                                *)
  766.     scsiBusWide16*                = $20;                            (* Supports 16 bit wide SCSI                                *)
  767.     scsiBusSDTR*                    = $10;                            (* Supports Sync Data Transfer Req message                    *)
  768.     scsiBusLinkedCDB*            = $08;                            (* Supports linked CDBs                                        *)
  769.     scsiBusTagQ*                    = $02;                            (* Supports tag queue message                                *)
  770.     scsiBusSoftReset*            = $01;                            (* Supports soft reset                                        *)
  771.  
  772. (* scsiDataTypes field bits  *)
  773. (*    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31* = reserved *)
  774.     scsiBusDataTIB*                = ASH(1,scsiDataTIB);    (* TIB supplied (ptr in scsiDataPtr)        *)
  775.     scsiBusDataBuffer*            = ASH(1,scsiDataBuffer); (* single contiguous buffer supplied         *)
  776.     scsiBusDataSG*                = ASH(1,scsiDataSG);    (* scatter/gather list supplied             *)
  777.     scsiBusDataReserved*            = $80000000;                    (*                                           *)
  778.  
  779. (* scsiScanFlags field bits *)
  780.     scsiBusScansDevices*            = $80;                            (* Bus scans for and maintains device list            *)
  781.     scsiBusScansOnInit*            = $40;                            (* Bus scans performed at power-up/reboot            *)
  782.     scsiBusLoadsROMDrivers*        = $20;                            (* may load ROM drivers to support targets             *)
  783.  
  784. (* scsiFeatureFlags field bits *)
  785.     scsiBusInternalExternalMask*    = $000000C0;                    (* bus internal/external mask                    *)
  786.     scsiBusInternalExternalUnknown* = $00000000;                    (* not known whether bus is inside or outside     *)
  787.     scsiBusInternalExternal*        = $000000C0;                    (* bus goes inside and outside the box             *)
  788.     scsiBusInternal*                = $00000080;                    (* bus goes inside the box                         *)
  789.     scsiBusExternal*                = $00000040;                    (* bus goes outside the box                     *)
  790.     scsiBusCacheCoherentDMA*        = $00000020;                    (* DMA is cache coherent                         *)
  791.     scsiBusOldCallCapable*        = $00000010;                    (* SIM is old call capable                         *)
  792.     scsiBusDifferential*            = $00000004;                    (* Single Ended (0) or Differential (1)         *)
  793.     scsiBusFastSCSI*                = $00000002;                    (* HBA supports fast SCSI                         *)
  794.     scsiBusDMAavailable*            = $00000001;                    (* DMA is available                             *)
  795.  
  796. (* scsiWeirdStuff field bits *)
  797.     scsiOddDisconnectUnsafeRead1* = $0001;                        (* Disconnects on odd byte boundries are unsafe with DMA and/or blind reads *)
  798.     scsiOddDisconnectUnsafeWrite1* = $0002;                        (* Disconnects on odd byte boundries are unsafe with DMA and/or blind writes *)
  799.     scsiBusErrorsUnsafe*            = $0004;                        (* Non-handshaked delays or disconnects during blind transfers may cause a crash *)
  800.     scsiRequiresHandshake*        = $0008;                        (* Non-handshaked delays or disconnects during blind transfers may cause data corruption *)
  801.     scsiTargetDrivenSDTRSafe*    = $0010;                        (* Targets which initiate synchronous negotiations are supported *)
  802.  
  803. (* scsiHBAslotType values *)
  804.     scsiMotherboardBus*            = $01;                            (* A built in Apple supplied bus                     *)
  805.     scsiNuBus*                    = $02;                            (* A SIM on a NuBus card                             *)
  806.     scsiPDSBus*                    = $03;                            (*    "  on a PDS card                                *)
  807.     scsiPCIBus*                    = $04;                            (*    "  on a PCI bus card                            *)
  808.     scsiPCMCIABus*                = $05;                            (*    "  on a PCMCIA card                            *)
  809.     scsiFireWireBridgeBus*        = $06;                            (*    "  connected through a FireWire bridge        *)
  810.  
  811. (* Defines for the scsiDriverFlags field (in SCSIDriverPB) *)
  812.     scsiDeviceSensitive*            = $0001;                        (* Only driver should access this device                *)
  813.     scsiDeviceNoOldCallAccess*    = $0002;                        (* no old call access to this device                     *)
  814.  
  815. (*  SIMInitInfo PB *)
  816. (* directions are for SCSIRegisterBus call ( -> parm, <- result)             *)
  817.  
  818. TYPE
  819.     SIMInitInfo* = RECORD
  820.         SIMstaticPtr*:            SYSTEM.PTR (*ΔΔ POINTER TO UInt8*);                                    (* <- alloc. ptr to the SIM's static vars                 *)
  821.         staticSize*:                LONGINT;                                (* -> num bytes SIM needs for static vars                 *)
  822.         SIMInit*:                SIMInitUPP;                                (* -> pointer to the SIM init routine                     *)
  823.         SIMAction*:                SIMActionUPP;                            (* -> pointer to the SIM action routine                 *)
  824.         SIM_ISR*:                SCSIInterruptUPP;                        (*       reserved                                             *)
  825.         SIMInterruptPoll*:        SCSIInterruptUPP;                        (* -> pointer to the SIM interrupt poll routine            *)
  826.         NewOldCall*:                SIMActionUPP;                            (* -> pointer to the SIM NewOldCall routine                *)
  827.         ioPBSize*:                Types.UInt16;                                    (* -> size of SCSI_IO_PBs required for this SIM            *)
  828.         oldCallCapable*:            BOOLEAN;                                (* -> true if this SIM can handle old-API calls            *)
  829.         simInfoUnused1*:            Types.SInt8; (* UInt8 *)                        (*       reserved                                            *)
  830.         simInternalUse*:            LONGINT;                                (* xx not affected or viewed by XPT                        *)
  831.         XPT_ISR*:                SCSIUPP;                                (*    reserved                                            *)
  832.         EnteringSIM*:            SCSIUPP;                                (* <- ptr to the EnteringSIM routine                    *)
  833.         ExitingSIM*:                SCSIUPP;                                (* <- ptr to the ExitingSIM routine                        *)
  834.         MakeCallback*:            SCSIMakeCallbackUPP;                    (* <- the XPT layer’s SCSIMakeCallback routine            *)
  835.         busID*:                    Types.UInt16;                                    (* <- bus number for the registered bus                    *)
  836.         simInfoUnused3*:            Types.UInt16;                                    (* <- reserved                                            *)
  837.         simInfoUnused4*:            LONGINT;                                (* <- reserved                                            *)
  838.     END;
  839.  
  840. (* Glue between SCSI calls and SCSITrap format *)
  841.  
  842. CONST
  843.     xptSCSIAction*                = $0001;
  844.     xptSCSIRegisterBus*            = $0002;
  845.     xptSCSIDeregisterBus*        = $0003;
  846.     xptSCSIReregisterBus*        = $0004;
  847.     xptSCSIKillXPT*                = $0005;                        (* kills Mini-XPT after transition *)
  848.     xptSCSIInitialize*            = $000A;                        (* Initialize the SCSI manager *)
  849.  
  850. (* SCSI status*)
  851.     scsiStatGood*                = $00;                            (* Good Status*)
  852.     scsiStatCheckCondition*        = $02;                            (* Check Condition*)
  853.     scsiStatConditionMet*        = $04;                            (* Condition Met*)
  854.     scsiStatBusy*                = $08;                            (* Busy*)
  855.     scsiStatIntermediate*        = $10;                            (* Intermediate*)
  856.     scsiStatIntermedMet*            = $14;                            (* Intermediate - Condition Met*)
  857.     scsiStatResvConflict*        = $18;                            (* Reservation conflict*)
  858.     scsiStatTerminated*            = $20;                            (* Command terminated*)
  859.     scsiStatQFull*                = $28;                            (* Queue full*)
  860.  
  861. (* SCSI messages*)
  862.     kCmdCompleteMsg*                = 0;
  863.     kExtendedMsg*                = 1;                            (* 0x01*)
  864.     kSaveDataPointerMsg*            = 2;                            (* 0x02*)
  865.     kRestorePointersMsg*            = 3;                            (* 0x03*)
  866.     kDisconnectMsg*                = 4;                            (* 0x04*)
  867.     kInitiatorDetectedErrorMsg*    = 5;                            (* 0x05*)
  868.     kAbortMsg*                    = 6;                            (* 0x06*)
  869.     kMsgRejectMsg*                = 7;                            (* 0x07*)
  870.     kNoOperationMsg*                = 8;                            (* 0x08*)
  871.     kMsgParityErrorMsg*            = 9;                            (* 0x09*)
  872.     kLinkedCmdCompleteMsg*        = 10;                            (* 0x0a*)
  873.     kLinkedCmdCompleteWithFlagMsg* = 11;                            (* 0x0b*)
  874.     kBusDeviceResetMsg*            = 12;                            (* 0x0c*)
  875.     kAbortTagMsg*                = 13;                            (* 0x0d*)
  876.     kClearQueueMsg*                = 14;                            (* 0x0e*)
  877.     kInitiateRecoveryMsg*        = 15;                            (* 0x0f*)
  878.     kReleaseRecoveryMsg*            = 16;                            (* 0x10*)
  879.     kTerminateIOProcessMsg*        = 17;                            (* 0x11*)
  880.     kSimpleQueueTag*                = $20;                            (* 0x20*)
  881.     kHeadOfQueueTagMsg*            = 33;                            (* 0x21*)
  882.     kOrderedQueueTagMsg*            = 34;                            (* 0x22*)
  883.     kIgnoreWideResidueMsg*        = 35;                            (* 0x23*)
  884.  
  885. (* moveq #kSCSIx, D0;  _SCSIAtomic *)
  886.  
  887. PROCEDURE SCSIAction*(VAR parameterBlock: SCSI_PB): Types.OSErr;
  888.     (*$IF NOT GENERATINGCFM*)
  889.     INLINE PASCAL $205F, $7001, $A089, $3E80;
  890.     (*$END*)
  891. PROCEDURE SCSIRegisterBus*(VAR parameterBlock: SIMInitInfo): Types.OSErr;
  892.     (*$IF NOT GENERATINGCFM*)
  893.     INLINE PASCAL $205F, $7002, $A089, $3E80;
  894.     (*$END*)
  895. PROCEDURE SCSIDeregisterBus*(VAR parameterBlock: SCSI_PB): Types.OSErr;
  896.     (*$IF NOT GENERATINGCFM*)
  897.     INLINE PASCAL $205F, $7003, $A089, $3E80;
  898.     (*$END*)
  899. PROCEDURE SCSIReregisterBus*(VAR parameterBlock: SIMInitInfo): Types.OSErr;
  900.     (*$IF NOT GENERATINGCFM*)
  901.     INLINE PASCAL $205F, $7004, $A089, $3E80;
  902.     (*$END*)
  903. PROCEDURE SCSIKillXPT*(VAR parameterBlock: SIMInitInfo): Types.OSErr;
  904.     (*$IF NOT GENERATINGCFM*)
  905.     INLINE PASCAL $205F, $7005, $A089, $3E80;
  906.     (*$END*)
  907.  
  908. (* $ALIGN RESET*)
  909. (* $POP*)
  910.  
  911.  END SCSI.
  912.